{% load sitetags %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style>
        .wrapper{align-content: center; width: 1000px; height: 100%; margin: 40px auto;
            font-size: 20px; color: black; background-color:rgba(0,0,0,0.01);}
        a:hover{color: rebeccapurple;}
        a{color: rgb(46,117,181);}
        table{width: 100%; text-align: center; margin-top: 20px; font-size: 15px; word-break : break-all;
            border: 1px solid gray; border-spacing: 0; border-collapse: collapse;}
        tr,td{border: 1px solid gray; padding: 6px;}
        .title1 {background-color: rgb(46,117,181); color: white; font-size: 18px;}
        .title2{background-color: rgb(222,234,246);}
        caption{text-align: left; padding-left: 40px; font-size: 20px;}
        .nav{vertical-align: middle; height: 60px; border-top: 100px; background-color: #f5f5f5;
            content: ""; display: block; clear: both;}
        .nav .logo{line-height: 50px; float: left;}
        .nav .main{line-height: 60px;float: left;padding-left: 2px;}
        .section{margin-top: 20px;}
        .text-indent{padding-left: 40px;}
        .t-sec{font-size: 10px;color: rgba(108, 108, 96, 0.78);}
    </style>
</head>
<body style="width: 100%;" >
{% get_website_url as own_site_url %}
<div class="wrapper">
    <div class="nav">
        <div class="logo">
            <a href="https://service.cstcloud.cn/"><img style="vertical-align: middle; height: 40px" src="{{ own_site_url }}/app/main/img/cstcloud_logo.22d98e7b.png"/></a>
        </div>
        <div class="main"><span style="font-size: 21px;">一体化云服务平台</span></div>
    </div>
    <div>
        <p>尊敬的 {{ user.username }}，您好！<br/>
         <span class="text-indent">感谢您使用中国科技云一体化云服务平台，以下为您<span style="font-weight: bold">{{ report_period_start_time|date:'Y年m月d日' }}0时至{{ report_period_end_time|date:'Y年m月d日' }}24时</span>资源用量结算情况和账户资源券情况。
         </span>
        </p>
    </div>
    <div>
        {% if monthly_report.has_resources %}
        <table>
            <caption>
                个人资源使用结算情况，月度汇总: {{ monthly_report.total_payment_amount }} 点
            </caption>
            {% if monthly_report.server_count %}
            <tr>
                <td colspan="9" class="title1">开放科学云主机（数量：{{ monthly_report.server_count }}，总结算点数：{{ monthly_report.server_payment_amount }}）</td>
            </tr>
            <tr class="title2">
                <td style="width: 14%;">云主机IP</td>
                <td style="width: 10%;">公网IP<br>（个*天）</td>
                <td style="width: 11%;">vCPU<br>（核*天）</td>
                <td style="width: 11%;">内存<br>（GB*天）</td>
                <td style="width: 11%;">系统硬盘<br>（GB*天）</td>
                <td style="width: 11%">网络费用</td>
                <td style="width: 12%">计量点数</td>
                <td style="width: 12%">结算点数</td>
                <td style="width: 8%">用量明细</td>
            </tr>
                {% for mr in user_server_reports %}
                <tr class="content">
                    <td>{{ mr.server.ipv4 }}</td>
                    <td>{{ mr.total_public_ip_hours|floatformat:2 }}</td>
                    <td>{{ mr.total_cpu_hours|floatformat:2 }}</td>
                    <td>{{ mr.total_ram_hours|floatformat:2 }}</td>
                    <td>{{ mr.total_disk_hours|floatformat:2 }}</td>
                    <td>10Gb科技网共享限量免费</td>
                    <td>{{ mr.total_original_amount|floatformat:2 }}</td>
                    <td>{{ mr.total_amount|floatformat:2 }}</td>
                    {% if forloop.first %}
                    <td rowspan="{{ user_server_reports|length }}"><a target="view_window" href="{{ own_site_url }}/my/stats/consumption/personal">点击查看使用明细</a></td>
                    {% endif %}
                </tr>
                {% endfor %}
            {% endif %}
            {% if user_disk_reports %}
            <tr class="title1">
                <td colspan="9">云硬盘（数量：{{ monthly_report.disk_count }}，总结算点数：{{ monthly_report.disk_payment_amount }}）</td>
            </tr>
            <tr class= "title2">
                <td colspan="2">云硬盘ID和备注</td>
                <td colspan="1">容量（GB）</td>
                <td colspan="2">容量用量（GB*天）</td>
                <td>网络费用</td>
                <td>计量点数</td>
                <td>结算点数</td>
                <td>用量明细</td>
            </tr>
            {% for dmr in user_disk_reports %}
            <tr class="content">
                <td colspan="2"><span class="t-sec">{{ dmr.disk.id }}</span><br>{{ dmr.disk.remarks }}</td>
                <td>{{ dmr.disk.size}}</td>
                <td colspan="2">{{ dmr.total_size_hours|floatformat:2 }}</td>
                <td>10Gb科技网共享限量免费</td>
                <td>{{ dmr.total_original_amount|floatformat:2 }}</td>
                <td>{{ dmr.total_amount|floatformat:2 }}</td>
                {% if forloop.first %}
                <td rowspan="{{ user_disk_reports|length }}"><a target="view_window" href="{{ own_site_url }}/my/stats/consumption/personal">点击查看使用明细</a></td>
                {% endif %}
            </tr>
            {% endfor %}
            {% endif %}
            {% if bucket_reports %}
            <tr class="title1">
                <td colspan="9">对象存储（存储桶数量：{{ bucket_reports_len }}，总结算点数：{{ monthly_report.storage_postpaid_amount }}）</td>
            </tr>
            <tr class= "title2">
                <td colspan="3">存储桶名称</td>
                <td colspan="2">存储用量（GB*天）</td>
                <td>网络费用</td>
                <td>计量点数</td>
                <td>结算点数</td>
                <td>用量明细</td>
            </tr>
            {% for b in bucket_reports %}
                <tr>
                    <td colspan="3">{{ b.bucket_name }}</td>
                    <td colspan="2">{{ b.storage_days | floatformat:2 }}</td>
                    <td>10Gb科技网共享限量免费</td>
                    <td>{{ b.original_amount }}</td>
                    <td>{{ b.payable_amount }}</td>
                    {% if forloop.first %}
                        <td rowspan="{{ bucket_reports_len }}"><a target="view_window" href="{{ own_site_url }}/my/stats/consumption/storage" >点击查看使用明细</a></td>
                    {% endif %}
                </tr>
            {% endfor %}
            {% endif %}
        </table>
    {% endif %}
    </div>
    <div>
        {% if vo_monthly_reports %}
        <table>
            <caption>
                项目组资源使用结算情况
            </caption>
            <tr class="title1">
                <td colspan="20">开放科学云主机（项目组数量：{{ vo_monthly_reports|length }}，总结算点数：{{ vo_total_amount }}）</td>
            </tr>
            <tr class="title2">
                <td colspan="2" style="width: 10%;"><span>项目组名称</span></td>
                <td colspan="3" style="width: 20%;">组信息</td>
                <td colspan="3" style="width: 6%;">我的身份</td>
                <td colspan="3" style="width: 6%;">资源数量</td>
                <td colspan="2" style="width: 14%;">结算点数</td>
                <td colspan="6" style="width: 22%">本月资源用量</td>
                <td colspan="2" style="width: 12%">用量明细</td>
            </tr>
            {% for vmr in vo_monthly_reports %}
                {% with vo_info=vmr.vo_info %}
                    <tr>
                        <td colspan="2">
                            <a target="view_window" href="{{ own_site_url }}/my/server/group/detail/{{ vo_info.vo.id }}">{{ vo_info.vo.name }}</a></td>
                        <td colspan="3" style="text-align: left;">
                            <div style="padding-top: 0;margin-top: 0">
                                组长: {{ vo_info.vo.owner.username }}
                            </div>
                            {% if vo_info.admin_members %}
                                <div style="padding-top: 0;margin-top: 0">管理员: <br>{% for m in vo_info.admin_members %}{{ m.user__username }}<br>{% endfor %} </div>
                            {% endif %}
                            {% if vo_info.normal_members %}
                                <div style="padding-top: 0;margin-top: 0">组员: <br>{% for m in vo_info.normal_members %}{{ m.user__username }}<br>{% endfor %}</div>
                            {% endif %}
                        </td>
                        <td colspan="3">{{ vo_info.own_role }}</td>
                        <td colspan="3">云主机 {{ vmr.server_count }}{% if vmr.disk_count %}<br><br>云硬盘 {{ vmr.disk_count }}{% endif %}</td>
                        <td colspan="2">{{ vmr.server_disk_payment_amount }}</td>
                        <td colspan="6">
                            云主机：<br>
                            公网IP {{ vmr.server_ip_days | floatformat:2 }} 个*天， <br>
                            vCPU {{ vmr.server_cpu_days | floatformat:2 }} 核*天，<br>
                            内存 {{ vmr.server_ram_days | floatformat:2 }} GB*天，<br>
                            系统硬盘 {{ vmr.server_disk_days | floatformat:2 }} GB*天<br>
                            计量点数 {{ vmr.server_original_amount | floatformat:2 }}<br>
                            {% if vmr.disk_count %}<br>云硬盘：<br>
                            容量 {{ vmr.disk_size_days | floatformat:2 }} GB*天<br>
                            计量点数 {{ vmr.disk_original_amount | floatformat:2 }}{% endif %}
                        </td>
                        <td colspan="2"><a target="view_window" href="{{ own_site_url }}/my/stats/consumption/group/metering/{{ vo_info.vo.id }}">点击查询用量明细</a></td>
                    </tr>
                {% endwith %}
            {% endfor %}
        </table>
    {% endif %}
    </div>
    <div class="section">
        {% if user_coupons_length or vo_coupons_length %}
        <span class="text-indent">资源券情况</span>
        {% if user_coupons_length %}
        <table style="margin-top: 0;">
            <tr><td colspan="6" class="title1">个人资源券（{{ user_coupons_length }}张）</td></tr>
            <tr class="title2">
                <td style="width: 14%;">资源券编号</td>
                <td style="width: 18%;">到期时间</td>
                <td style="width: 24%;">服务单元</td>
                <td style="width: 16%;">资源类型</td>
                <td style="width: 14%;">剩余点数</td>
                <td style="width: 14%;">本期结算点数</td>
            </tr>
            {% for uc in user_normal_coupons %}
                <tr >
                    <td>{{ uc.id }}</td>
                    <td>{{ uc.expiration_time | date:'Y-m-d H:i:s' }}</td>
                    <td>{{ uc.app_service.name }}</td>
                    <td>{% if uc.app_service.category == 'vms-server' %}开放科学云主机
                        {% elif uc.app_service.category == 'vms-object' %}对象存储
                        {% elif uc.app_service.category == 'vms-monitor' %}监控
                        {% elif uc.app_service.category == 'high-cloud' %}高等级云
                        {% elif uc.app_service.category == 'hpc' %}高性能计算
                        {% else %}其他{% endif %}
                    </td>
                    <td>{{ uc.balance }}</td>
                    <td>{{ uc.last_month_pay_amount }}</td>
                </tr>
            {% endfor %}
            {% for uc in user_expired_coupons %}
                <tr >
                    <td>{{ uc.id }}</td>
                    <td>{{ uc.expiration_time | date:'Y-m-d H:i:s' }}(过期)</td>
                    <td>{{ uc.app_service.name }}</td>
                    <td>{% if uc.app_service.category == 'vms-server' %}开放科学云主机
                        {% elif uc.app_service.category == 'vms-object' %}对象存储
                        {% elif uc.app_service.category == 'vms-monitor' %}监控
                        {% elif uc.app_service.category == 'high-cloud' %}高等级云
                        {% elif uc.app_service.category == 'hpc' %}高性能计算
                        {% else %}其他{% endif %}
                    </td>
                    <td>{{ uc.balance }}</td>
                    <td>{{ uc.last_month_pay_amount }}</td>
                </tr>
            {% endfor %}
        </table>
        {% endif %}
        {% if vo_coupons_length %}
        <table style="padding-top:0;margin-top: 0;border-top: none">
            <tr><td colspan="7" class="title1">项目组资源券（{{ vo_coupons_length }}张）</td></tr>
            <tr class="title2">
                <td style="width: 12%;" >资源券id</td>
                <td style="width: 10%;" >到期时间</td>
                <td style="width: 14%;" >服务单元</td>
                <td style="width: 14%;" >资源类型</td>
                <td style="width: 16%;" >项目组名称</td>
                <td style="width: 12%;" >剩余点数</td>
                <td style="width: 10%;" >本期结算点数</td>
            </tr>
            {% if vo_normal_coupons %}
                {% for vc in vo_normal_coupons %}
                    <tr >
                        <td>{{ vc.id }}</td>
                        <td>{{ vc.expiration_time | date:'Y-m-d H:i:s' }}</td>
                        <td>{{ vc.app_service.name }}</td>
                        <td>{% if vc.app_service.category == 'vms-server' %}开放科学云主机
                        {% elif vc.app_service.category == 'vms-object' %}对象存储
                        {% elif vc.app_service.category == 'vms-monitor' %}监控
                        {% elif vc.app_service.category == 'high-cloud' %}高等级云
                        {% elif vc.app_service.category == 'hpc' %}高性能计算
                        {% else %}其他{% endif %}</td>
                        <td>{{ vc.vo.name }}</td>
                        <td>{{ vc.balance }}</td>
                        <td>{{ vc.last_month_pay_amount }}</td>
                    </tr>
                {% endfor %}
            {% endif %}
            {% if vo_expired_coupons %}
                {% for vc in vo_expired_coupons %}
                    <tr>
                        <td>{{ vc.id }}</td>
                        <td>{{ vc.expiration_time | date:'Y-m-d H:i:s' }} (过期)</td>
                        <td>{{ vc.app_service.name }}</td>
                        <td>{% if vc.app_service.category == 'vms-server' %}开放科学云主机
                            {% elif vc.app_service.category == 'vms-object' %}对象存储
                            {% elif vc.app_service.category == 'vms-monitor' %}监控
                            {% elif vc.app_service.category == 'high-cloud' %}高等级云
                            {% elif vc.app_service.category == 'hpc' %}高性能计算
                            {% else %}其他{% endif %}
                        </td>
                        <td>{{ vc.vo.name }}</td>
                        <td>{{ vc.balance }}</td>
                        <td>{{ vc.last_month_pay_amount }}</td>
                    </tr>
                {% endfor %}
            {% endif %}
        </table>
        {% endif %}
        {% else %}<p class="text-indent">您的账户暂无可用资源券。</p>{% endif %}
    </div>
    <div style="margin-top: 10px;">
        <div style="line-height:2em;" class="text-indent">资源券获取方法:</div>
        <div>
        <span class="text-indent">1.中科院内相关科研合作项目可以申请测试用资源（试用7天），或关注中国科技云相关动态获取免费资源。</span><br>
        <span class="text-indent">2.其它项目用途根据中国科技云云主机成本均摊标准签订协议使用资源。</span><br>
        <span class="text-indent">您可以联系张老师（yzhang@cnic.cn）咨询相关信息。</span></div>
    </div>
    <div class="text-indent"><p>欢迎登录一体化云服务平台网站（<a target="view_window" href="{{ own_site_url }}">{{ own_site_url }}</a>）查询更多信息。</p></div>
</div>
</body>
</html>
